/**
 * File		: Vector4.java
 * Subject	: Represents a vector with three coordinates and W
 * Author	: Isaac Parenteau (locus2k@gmail.com)
 * Date		: May 3rd, 2011
 */
package opengameflow.framework.vector;

import opengameflow.framework.interfaces.IComparable;

public class Vector4 implements IComparable<Vector4>{

	public float x;
	public float y;
	public float z;
	public float w;
	
	public Vector4() {
		this(0, 0, 0, 0);
	}
	
	public Vector4(float x, float y, float z, float w) {
		this.x = x;
		this.y = y;
		this.z = z;
		this.w = w;
	}
	
	/**
	 * Gets the distance between two vectors
	 * @param other 
	 * @return distance between the vectors
	 */
	public float distance(Vector4 other){
		float xDif = this.x - other.getX();
		float yDif = this.y - other.getY();
		float zDif = this.z - other.getZ();
		
		xDif *= xDif;
		yDif *= yDif;
		zDif *= zDif;
		
		float distance = (float) Math.sqrt(xDif + yDif + zDif);
		
		return distance;
	}
	
	/**
	 * Normalizes the vector to a unit vector
	 * @param other other vector to normalize between
	 * @return normalized vector
	 */
	public Vector4 normalize(Vector4 other){
		float distance = distance(other);
		
		float xDist = this.x / distance;
		float yDist = this.y / distance;
		float zDist = this.z / distance;
		
		return new Vector4(xDist, yDist, zDist, 1f);
	}
	
	/**
	 * Adds a vector to the current vector and returns 
	 * a new vector with the added values
	 * @param other other vector to add
	 * @return new vector3 with the other values
	 */
	public Vector3 add(Vector4 other){
		return new Vector3(this.x + other.getX(),
				this.y + other.getY(), this.z + other.getZ());
	}
	
	/**
	 * Adds another vector to the current vector
	 * @param other other vector to add
	 */
	public void addVector(Vector4 other){
		this.x += other.getX();
		this.y += other.getY();
		this.z += other.getZ();
	}
	
	public float getX() { return this.x; }
	public void setX(float x) { this.x = x; }
	public float getY() { return this.y; }
	public void setY(float y) { this.y = y; }
	public float getZ() { return this.z; }
	public void setZ(float z) { this.z = z; }
	public float getW() { return this.w; }
	public void setW(float w) { this.w = w; }
	
	public static Vector4 Up = new Vector4(0,1,0,1);
	public static Vector4 Zero = new Vector4(0,0,0,1);

	public boolean equals(Vector4 other) {
		// TODO Auto-generated method stub
		return false;
	}

	@Override
	public int compareTo(Vector4 obj) {
		// TODO Auto-generated method stub
		return 0;
	}
	
	
}
